package com.gingko.duominuo.ui.adapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gingko.duominuo.databinding.ItemReviewConditionsBinding

class ReviewConditionsAdapter(val context: Context, val data: List<String>) : RecyclerView.Adapter<ReviewConditionsAdapter.ReviewConditionHolder>() {

    inner class ReviewConditionHolder(private val viewBinding: ItemReviewConditionsBinding) : RecyclerView.ViewHolder(viewBinding.root) {

        @SuppressLint("SetTextI18n")
        fun bind(reviewCondition: String, position: Int) {
            viewBinding.tvCondition.text = reviewCondition
        }
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReviewConditionHolder {
        return ReviewConditionHolder(
            ItemReviewConditionsBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: ReviewConditionHolder, position: Int) {
        holder.bind(data[position], position)
    }

    override fun getItemCount(): Int {
        return data.size
    }
}